import axios from 'axios'
export default {
  namespaced: true,
  state: {
    allData: {}
  },
  mutations: {
    updateList (state, { currentCategtory, list }) {
      state.allData = { ...state.allData, [currentCategtory]: list }
    }
  },
  actions: {
    async getNewList (context, cataId) {
      const { data: { data: { results } } } = await
      axios.get(`http://ttapi.research.itcast.cn/app/v1_1/articles?channel_id=${cataId}&timestamp=${Date.now()}&with_top=1`)
      context.commit('updateList', { currentCategtory: cataId, list: results })
      console.log(context.state.allData)
      console.log(this.state.allData)
      console.log(777777)
    }
  }
}
